home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / util / Mac F2C 1.3.sit / Mac F2C 1.3 / Mac F2C Libraries / libF77 Sources / s_paus.c < prev    next >
Text File  |  1995-09-15  |  2KB  |  103 lines

  1.  
  2. /* IMT 10Sep95  Declare jump buffer used to recover from exception exits & aborts */
  3. #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C) 
  4. #include <setjmp.h>
  5. extern jmp_buf gRecoverToConsole;
  6. #endif /* Macintosh C compilers */
  7.  
  8.  
  9. #include "stdio.h"
  10. #include "f2c.h"
  11. #define PAUSESIG 15
  12.  
  13. #ifdef KR_headers
  14. #define Void /* void */
  15. #define Int /* int */
  16. #else
  17. #define Void void
  18. #define Int int
  19. #undef abs
  20. #undef min
  21. #undef max
  22. #include "stdlib.h"
  23. #include "signal.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. extern int getpid(void), isatty(int), pause(void);
  28. #endif
  29.  
  30. extern VOID f_exit(Void);
  31.  
  32.  static VOID
  33. waitpause(Int n)
  34. {    n = n; /* shut up compiler warning */
  35.     return;
  36.     }
  37.  
  38.  static VOID
  39. #ifdef KR_headers
  40. s_1paus(fin) FILE *fin;
  41. #else
  42. s_1paus(FILE *fin)
  43. #endif
  44. {
  45.     fprintf(stderr,
  46.     "To resume execution, type go.  Other input will terminate the job.\n");
  47.     fflush(stderr);
  48.     if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) {
  49.         fprintf(stderr, "STOP\n");
  50. #ifdef NO_ONEXIT
  51.         f_exit();
  52. #endif
  53.  
  54. /* IMT 10Sep95  Declare jump buffer used to recover from exception exits & aborts */
  55. #if defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C) 
  56.         longjmp( gRecoverToConsole, 1 );
  57. #else
  58.         exit(0);
  59. #endif /* Macintosh compilers */
  60.         }
  61.     }
  62.  
  63.  int
  64. #ifdef KR_headers
  65. s_paus(s, n) char *s; ftnlen n;
  66. #else
  67. s_paus(char *s, ftnlen n)
  68. #endif
  69. {
  70.     fprintf(stderr, "PAUSE ");
  71.     if(n > 0)
  72.         fprintf(stderr, " %.*s", (int)n, s);
  73.     fprintf(stderr, " statement executed\n");
  74.     if( isatty(fileno(stdin)) )
  75.         s_1paus(stdin);
  76.     else {
  77. #ifdef MSDOS
  78.         FILE *fin;
  79.         fin = fopen("con", "r");
  80.         if (!fin) {
  81.             fprintf(stderr, "s_paus: can't open con!\n");
  82.             fflush(stderr);
  83.             exit(1);
  84.             }
  85.         s_1paus(fin);
  86.         fclose(fin);
  87. #else
  88.         fprintf(stderr,
  89.         "To resume execution, execute a   kill -%d %d   command\n",
  90.             PAUSESIG, getpid() );
  91.         signal(PAUSESIG, waitpause);
  92.         fflush(stderr);
  93.         pause();
  94. #endif
  95.         }
  96.     fprintf(stderr, "Execution resumes after PAUSE.\n");
  97.     fflush(stderr);
  98.     return 0; /* NOT REACHED */
  99. #ifdef __cplusplus
  100.     }
  101. #endif
  102. }
  103.